package com.example.log.controller;

import com.example.log.annotation.RequiredLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    private static final Logger log= LoggerFactory.getLogger(HelloController.class);
    /**
     * 我希望使用@OperationLog注解描述的方法
     * 为一个日志切入点方法.
     * @param id
     * @return
     */
    @RequiredLog(operation="doHelloTest")
    @GetMapping("/api/hello/{id}")
    public Object doHello(@PathVariable("id") Long id){
        System.out.println("HelloController.thread.name="+Thread.currentThread().getName());
       // log.info("start:{}",System.currentTimeMillis());
        Object result="hello";
       // log.info("end:{}",System.currentTimeMillis());
        return result;
    }

}
